﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using FFmpegVideoClip.Mode.Files;

namespace FFmpegVideoClip.Lib.AdvancedFragmentProcessor
{
    //内部执行定义的处理过程，通过该类进行选择
    //与配置中的名称对应，并在【InternalProcessors】中注册
    public class InternalProcessorSelector
    {
        public readonly static ReadOnlyCollection<string> InternalProcessors = (new string[] { nameof(ChineseTSConverts) }).AsReadOnly();
        public static bool IsExistsInternalProcessors(AdvancedParametersSchemeModule Module) => InternalProcessors.Contains(Module.ProcessorName, StringComparer.OrdinalIgnoreCase);
        public static bool GetSelector(AdvancedParametersSchemeModule Module, out Action<AdvancedParametersSchemeModule, SuccessAndProgress> action)
        {
            action = null!;
            if (!IsExistsInternalProcessors(Module))
                return false;
            action = GetSelector(Module);
            return true;
        }
        public static Action<AdvancedParametersSchemeModule, SuccessAndProgress> GetSelector(AdvancedParametersSchemeModule Module) => Module.ProcessorName switch
        {
            string ProcessorName when ProcessorName.Equals("ChineseTSConverts", StringComparison.OrdinalIgnoreCase) => ChineseTSConverts.Convert,
            _ => throw new NotImplementedException($"不存在名为[{Module.SchemeName}]的处理器程序")
        };
    }
}
